class Ball
  
  class Position
    
    attr_accessor :x, :y
    
    def initialize(x, y)
      super()
      @x = x
      @y = y
      self
    end
    
    def ===(position)
      @x == position.x && @y == position.y
    end
    
    def up_1
      Position.new(@x, @y + 1)
    end

    def down_1
      Position.new(@x, @y - 1)
    end

    def left_1
      Position.new(@x - 1, @y)
    end

    def right_1
      Position.new(@x + 1, @y)
    end
    
  end
  
  attr_accessor :position, :name
  
  def initialize(x, y)
    super()
    @position = Position.new(x, y)
    self
  end
  
  def move_to(position)
    @position = position
  end
  
end
